/**
 * Created by aa on 2016/9/23.
 */
'use strict';
var utils = require('../common/utils');
var cac = utils.cac;

//基金基本信息
const RECEIVE_NORMAL_INFO = 'RECEIVE_NORMAL_INFO';
//基金业绩排名
const RECEIVE_FUND_PERFORMANCE='RECEIVE_FUND_PERFORMANCE';
//净值数据
const RECEIVE_FUND_NAV_HISLIST='RECEIVE_FUND_NAV_HISLIST';


//对外暴露变量
exports.RECEIVE_NORMAL_INFO = RECEIVE_NORMAL_INFO;
exports.RECEIVE_FUND_PERFORMANCE = RECEIVE_FUND_PERFORMANCE;
exports.RECEIVE_FUND_NAV_HISLIST = RECEIVE_FUND_NAV_HISLIST;

var receivFundNavHislist;

//对外暴露方法
exports.receiveNormalInfo = cac(RECEIVE_NORMAL_INFO, 'normalInfo');
exports.receivFundPerformance = cac(RECEIVE_FUND_PERFORMANCE, 'fundPerformance');
exports.receivFundNavHislist =receivFundNavHislist= cac(RECEIVE_FUND_NAV_HISLIST, 'fundNavHislist');

exports.getFundNavHisList=(fundCode,current)=>{
    return (dispatch, getState) => {
        reqwest({
            url: '/api/fundnavHisList',
            method: 'post',
            contentType: 'application/json',
            data: JSON.stringify({
                curPage: current,
                fundCode: fundCode
            })
        })
            .then(function (data) {
                dispatch(receivFundNavHislist(data));
            })
            .fail(function (err, msg) {
                alert('获取数据出错');
            })
    }
};